home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YPRINTER.C
< prev
next >
Wrap
Text File
|
1988-11-29
|
3KB
|
172 lines
/******************** YPRINTER.C: codes for EPSON printers *******************/
/*********************** (C) 1986,7,8 by JAMES A. YORKE **********************/
#include "yinclud.h"
char printstatus; /* given a value by printerStatus() */
#ifdef MS
#include <dos.h>
#define PUTC(x,y) putc(x,y);fflush(y)
#else
#define PUTC(x,y) putc(x,y)
#endif
carriage_return() {
C = 13; /* carriage return */
PUTC(C, stdprn);
}
print_graphics_mode() {
C = 27;
PUTC(C, stdprn); /* sends character C to printer */
C = 'L'; /* 960 bit image graphics mode */
PUTC(C, stdprn);
C = corecols % 256;
PUTC(C, stdprn);
C = corecols / 256;
PUTC(C, stdprn);
}
selectPrinterColor(col) /* col is color number */
int col;
{
C = ESC;
PUTC(C, stdprn);
C = 'r';
PUTC(C, stdprn);
C = col;
PUTC(C, stdprn);
}
iprint(f) /* initializes the printer spacing for graphics
*/
int f;
{
C = 27;
PUTC(C, stdprn);
C = '3';
PUTC(C, stdprn);
C = f;
PUTC(C, stdprn);
}
i12print() { /* initializes the printer for text */
C = 27;
PUTC(C, stdprn);
C = '3';
PUTC(C, stdprn);
C = 36;
PUTC(C, stdprn);
}
on_dbl_wdth() {
C = 27;
PUTC(C, stdprn);
C = 'W';
PUTC(C, stdprn);
C = 1;
PUTC(C, stdprn);
}
off_dbl_wdth() {
C = 27;
PUTC(C, stdprn);
C = 'W';
PUTC(C, stdprn);
C = 0;
PUTC(C, stdprn);
}
line_feed() { /* printer command */
C = 10; /* line feed to printer */
PUTC(C, stdprn);
}
#ifdef MS
#include <sys/types.h>
#include <sys/timeb.h>
double timeofday()
{
struct timeb timestruc;
ftime(×truc);
return((double) timestruc.time + (double) timestruc.millitm / 1000.0);
}
#endif /* MS */
#ifdef UNIX
/* The Unix version of timeofday() uses the TIMES(2) system call to
* get the total time used by the program. We ignore its return value
* because differing implementations return either 0 or the time since
* system startup. This version assumes that the user and child times
* are given in units of Hertz (1/60 sec).
* The return value of this function is the total time used by the program
* so far. It is not used as a wall clock in the X window version of the
* program.
*/
#include <sys/types.h>
#include <sys/times.h>
double timeofday()
{
struct tms buffer;
double total;
long times();
(void) times(&buffer);
total = buffer.tms_utime + buffer.tms_stime + buffer.tms_cutime +
buffer.tms_cstime;
return(total / 60.0);
}
#endif
printChar()
{
#ifdef MS
union REGS regs;
regs.h.ah = 0;
regs.h.al = C;
regs.x.dx = 0;
int86(23, ®s, ®s);/* BIOS interrupt 17H; */
#endif
}
int printerStatus(num) /* initializes the printer and returns status byte;
meaning of bit:
7 printer busy
6 Acknowledge
5 out of paper
4 selected
3 I/O error
2,1 not used
0 time out */
int num;/* if num == 1, initializes and fetches status byte;
if num == 2, just fetches status byte */
{
int statuus;
#ifdef MS
union REGS regs;
regs.h.ah = num;
/* regs.h.al = C;*/
regs.x.dx = 0;
int86(23, ®s, ®s);/* BIOS interrupt 17H; */
printstatus = regs.h.ah;
#endif
#ifdef DESMET
printstatus = num;
#asm
MOV DX,0000H
MOV AH,printstatus_
INT 17H
MOV printstatus_,AH
#
#endif /* DESMET */
statuus = printstatus;
return(statuus);
}